<template>
	<view class="" @tap="kkmxs">
		<view class="komhjxdfgs">
			<view class="w100 h100 vertical-center" v-if="imnxsd">
				<view class="" v-if="kkjmxcxf(imnxsd)" @tap="chaknsde">
					<image src="../../static/img/pdf.png" class="xcertsrt"></image>
				</view>
				<image @tap="llkxdf(imnxsd)" :src="imnxsd" class="w100 h100" mode="aspectFill" v-else></image>
			</view>
			<view class="vertical-center w100 h100 fz40" v-else>
				+
			</view>
		</view>
		<view class="fz26 mt5">
			{{name}}
			<!-- <text class="red">*</text> -->
		</view>
	</view>
	<view class="jllmcxfdsfsr vertical-center" v-if="isdrr">
		<view class="kxzczxrtxer pd">
			<view class="fz30 z3 pt20">
				类型
			</view>
			<view class="mt20 btm pt20 display-flex">
				<view class="kkxzcerexe vertical-center" @tap="uoinmhsd">
					<view class="cen">
						<image src="../../static/img/fdsfdsa.png" class="xcertsrt"></image>
						<view class="z9 fz26">
							图片
						</view>
					</view>
				</view>
				<view class="kkxzcerexe vertical-center ml20" @tap="upiddrtew">
					<view class="cen">
						<image src="../../static/img/pdf.png" class="xcertsrt"></image>
						<view class="z9 fz26">
							文件
						</view>
					</view>
				</view>
			</view>
			<view class="mt40">
				<button type="primary" size="mini" class="w100 fz32" @tap="isdrr=false">关闭</button>
			</view>
		</view>
	</view>
</template>
<script lang="ts" setup>
	import dxheader from "@/components/dxheader.vue"
	import { ref } from "vue"
	import { dxrequest, hf, upflie, upImg } from "@/util/index.js"
	const props = defineProps({
		keyName: { type: String },
		name: { type: String }
	});
	const imnxsd = ref()
	const emit = defineEmits([
		'close',
		'success'
	]);

	let jjnxr = false
	const isdrr = ref()
	const kkmxs = (data) => {
		isdrr.value = true
	}
	const kkjmxcxf = (data) => {
		let jnxs = false
		if (data.indexOf('.pdf')) {
			jnxs = true
		}
		if (data.indexOf('.zip')) {
			jnxs = true
		}
		return
	}
	const uoinmhsd = async () => {
		if (jjnxr) {
			return
		}
		jjnxr = true
		setTimeout(() => {
			jjnxr = false
		}, 2000)
		const { imgurl } = await upImg()
		imnxsd.value = imgurl
		emit("success", { key: props.keyName, imgurl })
		console.log(imgurl)
		isdrr.value = false
	}
	const upiddrtew = async () => {
		if (jjnxr) {
			return
		}
		jjnxr = true
		setTimeout(() => {
			jjnxr = false
		}, 2000)
		const { imgurl } = await upflie()
		imnxsd.value = imgurl
		emit("success", { key: props.keyName, imgurl })
		isdrr.value = false
	}
	const llkxdf = (data) => {
		// uni.previewImage({
		// 	urls:[data]
		// });
	}
</script>

<style scoped>
</style>